package com.hp.attendance.serlvet.attendanceCardSupplement;

import com.hp.attendance.entity.Employee;
import com.hp.attendance.service.CardService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;


@WebServlet("/passCard")
public class cardPassServlet extends HttpServlet {
    private CardService cardService=new CardService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        String date = req.getParameter("date");
        Employee emp = (Employee) req.getSession().getAttribute("emp");
        cardService.passCard(Integer.parseInt(id),emp.getEmployee_number(),date);
        req.getRequestDispatcher("/cardlist").forward(req,resp);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
